import streamlit as st

from video.video_demo import get_video_content

st.set_page_config(layout="wide")

st.title("🎦视频文案生成器")

# 定义布局（侧边栏）
with st.sidebar:
    #  定义标题
    st.title("视频文案生成器")
    st.divider()
    # 通义⼤模型密钥输⼊
    key = st.text_input("请输⼊通义大模型api key：")
    # key获取跳转链接
    st.page_link(
        "https://bailian.console.aliyun.com/?spm=5176.28326591.0.0.40f76ee1vUR5Of&accounttraceid=d873c9fe82ea443d9f3170f30dd5690cfnng#/api_key",
        label="⽆key？请点我获取", icon="♿")

    st.divider()

st.header("🎦视频文案成器")
subject = st.text_input("请输入视频主题")
time = st.number_input("请输入视频时长（单位：分钟）", min_value=0.0, max_value=6.0, value=0.1)
temperature = st.slider("创造性", min_value=0.0, max_value=2.0, value=1.0, step=0.1)
flag = st.button("生成")
if flag:
    if not key:
        st.info("请先输入通义大模型api key")
        st.stop()
    if not subject:
        st.info("请输入视频主题")
        st.stop()

    with st.spinner("正在生成视频文案，请稍等🥵🥵🥵"):
        title, response = get_video_content(key, subject, time, temperature)
        st.divider()
        st.header("🎦标题：")
        st.title(title)
        st.divider()
        st.write(response)
